module Backend (
builtinList,
defaultBackend,
- defaultHashBackend,
+ hashBackend,
genKey,
getBackend,
chooseBackend,
lookupBackendVariety,
lookupBuiltinBackendVariety,
maybeLookupBackendVariety,
+ unknownBackendVarietyMessage,
isStableKey,
isCryptographicallySecureKey,
isCryptographicallySecure,
valid name = not (null name)
lookupname = lookupBackendVariety . parseKeyVariety . encodeBS
+{- A hashing backend. Takes git config into account, but
+ - guarantees the backend is cryptographically secure. -}
+hashBackend :: Annex Backend
+hashBackend = do
+ db <- defaultBackend
+ return $ if isCryptographicallySecure db
+ then db
+ else defaultHashBackend
+
{- Generates a key for a file. -}
genKey :: KeySource -> MeterUpdate -> Backend -> Annex (Key, Backend)
genKey source meterupdate b = case B.genKey b of
, contentLocation = f
, inodeCache = Nothing
}
+
+recordVurlKey :: Backend -> OsPath -> Key -> [Key] -> Annex Bool
+recordVurlKey b f key eks = generateEquivilantKey b f >>= \case
+ Nothing -> return False
+ Just ek -> do
+ unless (ek `elem` eks) $
+ setEquivilantKey key ek
+ return True
import Logs.Remote
import Logs.EquivilantKeys
import Backend
-import Backend.VURL.Utilities (generateEquivilantKey)
+import Backend.VURL.Utilities (recordVurlKey)
import qualified Data.Map as M
| otherwise = return (Just v)
recordvurlkey eks = do
- -- Make sure to pick a backend that is cryptographically
- -- secure.
- db <- defaultBackend
- let b = if isCryptographicallySecure db
- then db
- else defaultHashBackend
- generateEquivilantKey b dest >>= \case
- Nothing -> return Nothing
- Just ek -> do
- unless (ek `elem` eks) $
- setEquivilantKey key ek
- return (Just Verified)
+ b <- hashBackend
+ ifM (recordVurlKey b dest key eks)
+ ( return (Just Verified)
+ , return Nothing
+ )
uploadKey :: Key -> AssociatedFile -> Maybe OsPath -> MeterUpdate -> Annex ()
uploadKey _ _ _ _ = giveup "upload to web not supported"